<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>CMS前端管理系统</title>
    <meta name="author" content="CMS">
   
    <link rel="stylesheet" media="screen" href="/static/libs/layui/css/layui.css?v={:rand_number()}"/> 
    <!-- 布 局 样 式 -->
    <link rel="stylesheet" media="screen" href="/static/libs/css/global111.css?v={:rand_number()}"/>
    <link rel="stylesheet" media="screen" href="/static/common/font/iconfont.css?v={:rand_number()}"/>
    <!-- 布 局 样 式 -->
    
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
    <!-- 布 局 框 架 -->
    <div class="layui-layout layui-layout-admin">
        <!-- 顶 部 样 式 -->
        <div class="layui-header">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <div class="logo"><i class="layui-icon layui-icon-component"></i></div>
                <!-- 标 题 -->
                <span class="title">CMS前端</span>
            </div>
            <!-- 顶 部 左 侧 功 能 -->
            <ul class="layui-nav layui-layout-left">
                <li class="collapse layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
                <li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
            </ul>
            <!-- 多 系 统 菜 单 -->
            <div id="control" class="layui-layout-control"></div>
            <!-- 顶 部 右 侧 菜 单 -->
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide-xs"><a href="{:getMyUrl()}" target="_blank" class="layui-icon layui-icon-website"></a></li>
                <!-- <li class="layui-nav-item layui-hide-xs"><a href="#" class="menuSearch layui-icon layui-icon-search"></a></li> -->
                <li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
                <li class="layui-nav-item"><a href="javascript:;"><i class="iconfont icon-trash" title="清空缓存"></i></a>
                        <dl class="layui-nav-child" id="deletecache">
                            <dd><a href="javascript:;" data-type="all">一键清理缓存<span class="layui-badge-dot"></span></a></dd>
                            <hr>
                            <dd><a href="javascript:;" data-type="all">清理数据缓存</a></dd>
                            <dd><a href="javascript:;" data-type="all">清理模板缓存</a></dd>
                            <dd><a href="javascript:;" data-type="all">清理插件缓存</a></dd>

                        </dl>
                </li>
                <li class="layui-nav-item user">
                    <!-- 头 像 -->
                    <a href="javascript:;"><img src="{$avatar}" class="layui-nav-img userAvatar" width="35" height="35">{$user.username}</a>
                    <!-- 功 能 菜 单 -->
                    <dl class="layui-nav-child">
                        <dd><a user-menu-url="{:url('user/profile')}" user-menu-id="3" user-menu-title="个人资料"><i class="iconfont icon-user-line"></i>&nbsp;个人资料</a></dd>
                        
                        <dd><a href="javascript:void(0);" class="logout"><i class="iconfont icon-logout-box-r-line"></i>&nbsp;注销登录</a></dd>

                        <dd><a user-menu-url="{:url('notice/message')}" user-menu-id="9" user-menu-title="最新消息"><i class="layui-icon layui-icon-notice"></i>最新消息{if $notice >'0'}<span class="layui-badge-dot"></span><!--小红点-->{/if}</a></dd>
                    </dl>
                </li>
                <!-- 主 题 配 置 -->
                <li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
            </ul>
        </div>
        <!-- 侧 边 区 域 -->
        <div class="layui-side layui-bg-black">
            <!-- 菜 单 顶 部 -->
            <div class="layui-logo">
                <!-- 图 标 -->
                <div class="logo"><i class="layui-icon layui-icon-component"></i></div>
                <!-- 标 题 -->
                <span class="title">ZtucCMS前端</span>
            </div>
            <!-- 菜 单 内 容 -->
            <div class="layui-side-scroll">
                <div class="sider-search menuSearch">
                    <div class="search-input">
                        <span class="search-text">搜索菜单</span>
                        <div class="search-icon"><i class="layui-icon layui-icon-search"></i></div>
                    </div>
                </div>
               <div id="sideMenu"></div>
            </div>
        </div>
        <!-- 视 图 页 面 -->
        <div class="layui-body">
            <!-- 内 容 页 面 -->
            <div id="content"></div>
        </div>
        <!-- 页脚 -->
        <div class="layui-footer layui-text">
            <span class="left">
          {:seo('copyright')}
            </span>
            <span class="center"></span>
            <span class="right">
          <b><span id="str"></span></b>
            </span>
        </div>
        <!-- 遮 盖 层 -->
        <div class="pear-cover"></div>
        <!-- 加 载 动 画 -->
        <div class="loader-main">
            <!-- 动 画 对 象 -->
            <div class="loader"></div>
        </div>
    </div>
    <!-- 移 动 端 便 捷 操 作 -->
    <div class="pear-collapsed-pe collapse">
        <a href="#" class="layui-icon layui-icon-shrink-right"></a>
    </div>
    <!-- 依 赖 脚 本 -->
   <script charset="utf-8" type="text/javascript" src="{__STATIC__}/libs/layui/layui.js?v={:rand_number()}"></script>
    <script type="text/javascript">
    layui.config({
       base: '{__STATIC__}/libs/layui_exts/'
    }).extend({
       admin: "pear/admin",           // 框架布局组件
       tab: "pear/tab",               // 多选项卡组件
       menu: "pear/menu",             // 数据菜单组件
       frame: "pear/frame",           // 内容页面组件
       theme: "pear/theme",           // 主题转换     
       fullscreen:"pear/fullscreen", // 全屏组件
       notice:"notice/notice",  // 消息 
    }).use(['layer', 'theme'], function () {
        layui.theme.changeTheme(window, false);
    })

   // 显示 Layui 版本
   document.getElementById("str").innerHTML = "Layui-v" + layui.v + " ";
    layui.use(['admin'], function() {
        var admin = layui.admin;
        var $ = layui.jquery;

        admin.render({
            "menu": {
                "data": "{:url('index')}",
                "method": "POST",
                "accordion": true,
                "collapse": false,
                "control": false,//菜单模式 false 为常规菜单，true 为多系统菜单
                "select": 0,
                "async": true
            }, 
            "tab": {
                "enable": true,
                "keepState": true,
                "session": true,
                "preload": true,
                "max": "10", 
                "index": {
                    "id": 0,
                    "href":"{:url('user/home')}",
                    "title": "首页"
                }
            }, 
            "theme": {
                "defaultColor": "2",
                "defaultMenu": "dark-theme",
                "defaultHeader": "light-theme",
                "allowCustom": true,
                "banner": false
            },
            "colors": [
                    {"id": "1", "color": "#2d8cf0", "second": "#ecf5ff"}, 
                    {"id": "2", "color": "#36b368", "second": "#f0f9eb"}, 
                    {"id": "3", "color": "#f6ad55", "second": "#fdf6ec"}, 
                    {"id": "4", "color": "#f56c6c", "second": "#fef0f0"}, 
                    {"id": "5", "color": "#3963bc", "second": "#ecf5ff"}
                ], 
            "other": {
                "keepLoad": "1200",
                "autoHead": false,
                "footer": false
            }
        });

        // 登出逻辑 
        admin.logout(function(){
            location.href = "{:url('user/logout')}";
            // 注销逻辑 返回 true / false
            return true;
        })

        //清除缓存
        $('body').on('click', "dl#deletecache dd a", function() {
            $.ajax({
                url: "{:url('user/clearTempLog')}",
                dataType: 'json',
                data: { type: $(this).data("type") },
                cache: false,
                success: function(res) {
                    if (res.code == 0) {
                        var index = layer.msg('清除缓存中，请稍候', { icon: 16, time: false, shade: 0.8 });
                        setTimeout(function() {
                            layer.close(index);
                            layer.msg("缓存清除成功！");
                        }, 1000);
                    }else{
                        layer.msg('清除缓存失败1');
                    }
                },
                error: function() {
                    layer.msg('清除缓存失败2');
                }
            });
        });

    })
    </script>    
    
    <script>
//开启轮询
        setInterval("test()",60000);
 
    //查询通知
    function test() {
        layui.use(['notice'], function () {
            var $ = layui.jquery;
            $.ajax({
                url: "{:url('notice/get_notice')}",
                async:true,
                type: 'get',
                success: function (res) {
                    if (res.data > '0'){
                        var notice = layui.notice;
                        notice.warning({
                            title: '消息通知',
                            message: '你今天有'+res.data+'条新的提醒待处理,请及时处理!',
                            audio:'5',
                            position:'bottomRight',
                            balloon:true,
                        });
                    }
                }
            })
        });
    }
</script>
</body>

</html>